﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="WorkFlow_Control_EmployeeSelect2" Codebehind="EmployeeSelect2.ascx.cs" %>
<table width="100%">
<tr>
    <td>
        <asp:TextBox ID="txtEmployeeNames" runat="server" Width="98%"></asp:TextBox></td>
    <td width="80px">
        
        <asp:Button runat="server" ID="btnSelect" onclick="btnSelect_Click" />
<asp:HiddenField runat="server" ID="hidValue" />
<asp:HiddenField runat="server" ID="hidText" />
        </td>
</tr>
</table>

<script language="javascript" type="text/javascript">
     function OrgEmployee() {
	        var ID;
	        var Name;
	 }
    function SelectEmployee<%=this.ClientID %>() {
        var empData = new Array();
        var vlist= document.getElementById("<%=hidValue.ClientID %>").value;
        var vlistName = document.getElementById("<%=hidText.ClientID %>").value;
        if(vlist!=null&&vlist!="")
        {
            var vlists=vlist.split(",");
            var vlistNames=vlistName.split(",");
            for(var i=0 ;i<vlists.length;i++)
            {
                empData[i]=new OrgEmployee();
                empData[i].ID=vlists[i];
                empData[i].Name=vlistNames[i];
            }
        }
        var url='<%=Page.ResolveClientUrl("~/") %>Workflow/OrgMapping/EmployeeSelect.aspx';
        var width= 600;
        var height=500;
        url += '?mode=<%=(int)SelectMode %>&randId=' + escape(new Date());
        var retValue = window.showModalDialog(url, empData, 'scroll:0;status:0;help:1;resizable:1;dialogWidth:'+width+'px;dialogHeight:'+height+'px');
        if (typeof (retValue) != "undefined" && retValue != null) {
            var ValueList = "";
            var TextList = "";
            for(var i=0;i<retValue.length;i++){
                if(retValue[i].ID!=null &&(retValue[i].ID+"")!="")
                {
                    if(ValueList!=""){
                        ValueList+=",";
                        TextList+=",";
                    }
                    ValueList+=retValue[i].ID;
                    TextList+=retValue[i].Name;
                }
            }
            if('<%=(int)SelectMode %>' == '<%=(int)Mode.Multi_Append %>'){
                if(vlist != ""){
                    vlist += ",";
                    vlistName += ",";
                }
                document.getElementById("<%=hidValue.ClientID %>").value=vlist + ValueList;
                document.getElementById("<%=hidText.ClientID %>").value=vlistName + TextList;                
            }
            else{
                document.getElementById("<%=hidValue.ClientID %>").value=ValueList;
                document.getElementById("<%=hidText.ClientID %>").value=TextList;
            }
            document.getElementById("<%=txtEmployeeNames.ClientID %>").value=document.getElementById("<%=hidText.ClientID %>").value;
            return true;
        }
        return false;
    }
</script>